PowerTCP Telnet for .NET CF
Read(Byte[]) Method
See Also  Example Send comments on this topic.
Dart.Common Namespace > TcpBase Class > Read Method : Read(Byte[]) Method




buffer
The byte array used to store the received data.
Receives data from the remote host.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Read( _
   ByVal buffer() As Byte _
) As Data
Visual Basic (Usage)Copy Code
Dim instance As TcpBase
Dim buffer() As Byte
Dim value As Data
 
value = instance.Read(buffer)
C# 
public Data Read( 
   byte[] buffer
)
Managed Extensions for C++ 
public: Data* Read( 
   byte[]* buffer
) 
C++/CLI 
public:
Data^ Read( 
   array<byte>^ buffer
) 

Parameters

buffer
The byte array used to store the received data.

Return Value

A Data object encapsulating the received data.

Example

This example demonstrates execution of a looping Read on a worker thread, and marshaling the data back to the UI. This specific example uses the Telnet component, but the code is the same for any component that derives from TcpBase.
C#Copy Code
//Receive data on a separate thread
telnet1.Start(receiveData, null);

private void receiveData(Telnet telnet, object notUsed)
{
	//Receive data when it is sent by the remote host
	byte[] buffer = new byte[1024];
	while (telnet.State != Dart.Common.ConnectionState.Closed)
		telnet.Marshal(telnet.Read(buffer, 0, 1024), null);
}
    
private void telnet1_Data(object sender, DataEventArgs e)
{
	//Whenever data is received, display it
	textDisplay.Text + e.Data.ToString();
}
Visual BasicCopy Code
'Receive data on a separate thread
telnet.Start(AddressOf receiveData, Nothing)
	
Private Sub receiveData(ByVal telnet As Telnet, ByVal notUsed As Object)
	'Receive data when it is sent by the remote host
	Dim buffer() As Byte = New Byte(1023){}
	Do While telnet.State <> ConnectionState.Closed
		telnet.Marshal(telnet.Read(buffer, 0, 1024), Nothing)
	Loop
End Sub
	
Private Sub telnet1_Data(ByVal sender As Object, ByVal e As DataEventArgs) Handles telnet1.Read
	'Whenever data is received, display it
	textDisplay.Text = e.Data.ToString()
End Sub

Remarks

This method will read as much data as is available, up to the size of the buffer.

This method will block until data is available or the ReceiveTimeout property has expired.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.2
© 2010 Dart Communications. All Rights Reserved.